#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "debugwindow.h"
#include "compilerinfo.h"
#include <vector>
#include <map>
#include <thread>
#include "systemCommands.h"
#include "Network.h"
#include <QSettings>
#include <QMessageBox>
#include "SwarmMessage.h"
#include <QProgressDialog>

using namespace SwarmHostSystemCommands;
enum DialogType {INFO_SHDT,ERROR_SHDT,WARN_SHDT,QUEST_SHDT};

class DebugWindow;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void closeDebugWindow(const int botnum);
    void communicationProcess();
    int writeMessage(string ip,string message);
    int writeMessage(int botnum, string message);
    bool refreshSwarmNet();

private slots:

    void on_browseButton_pressed();

    void on_dependencyButton_pressed();

    void on_compileButton_pressed();

    void on_push2SwarmButton_pressed();

    void on_playButton_toggled(bool checked);

    void on_removeSelectedFIle_pressed();

    void on_fileList_doubleClicked(const QModelIndex &index);

    void on_debugButton_clicked();

    void on_commandButton_clicked();

    void on_saveSettingsButton_clicked();

    void on_loadProjectButton_clicked();

    void on_newProjectButton_clicked();

    void on_playButton_clicked(bool checked);

    void on_actionImport_Settings_triggered();

    void on_actionExit_2_triggered();

    void on_actionSave_triggered();

    void on_clearControlConsoleButton_clicked();

    void on_clearProgramConsoleButton_clicked();

    void on_sendCommandButton_clicked();

    void on_deleteProjectButton_clicked();
    void on_commandEdit_returnPressed();

    void on_RefreshButton_clicked();
private:
    std::map<std::string,DebugWindow *> dbgDlgs;
    CompilerInfo compInfo;
    Ui::MainWindow *ui;

    bool killCommunicationThread;
    std::thread * communicationThread;
    std::string files2push;
    Network * SwarmNet;
    QSettings * settings;
    vector<string> ipsVector;
    mutex wmLock;

    // Private functions
    QMessageBox::StandardButton  messageUserDialog(DialogType,string,string);
    std::vector<std::vector<std::string>> receiveMessage();
    void refreshSettingDependentObjects();
    void pushAndLinkProcess(QProgressBar *bar);
};

#endif // MAINWINDOW_H


